package net.oschina.allchat.protocol.core;


public class ProtocolException extends RuntimeException {
	private static final long serialVersionUID = 1828997382595546258L;

	private IError error;
	
	public ProtocolException(IError error) {
		this.error = error;
	}
	
	public IError getError() {
		return error;
	}
	
	@Override
	public String getMessage() {
		return String.format("ProtocolException['%s', '%s', '%s']", error.getDefinedCondition(),
			(error.getText() == null ? null : error.getText().getText()),
					error.getApplicationSpecificCondition());
	}
	
	@Override
	public String toString() {
		return getMessage();
	}
}
